package com.request;

import java.io.ObjectOutputStream;
import java.util.Random;

import com.design.ClientForm;
import com.logic.PaymentVO;

public class ClientRequest 
{
	private Details details=null;
	private SocketConnection socketConnection=null;
	private String[] routerInfo=new String[2];
	private String[] clientInfo=new String[2];
	private int port=0;
	private String system=null;
	private ObjectOutputStream objectOutputStream=null;
	private ClientRequestVo clientRequestVo=null;
	private ClientDetails clientDetails=null;
	private PaymentVO paymentVO=null;
public ClientRequest() 
{
	details=new Details();
	paymentVO=new PaymentVO();
	//clientDetails=new ClientDetails();
	clientInfo=details.Config("clientport","clientsystem");
	clientRequestVo=new ClientRequestVo();
	socketConnection=new SocketConnection();
	
	routerInfo=details.Config("routerport","routersystem");
	port=Integer.parseInt(routerInfo[0]);
	system=routerInfo[1];
	
}	
public void smsRequest(String request)
{
	try
	{
		System.out.println("@@@@@@@@@");
		System.out.println(request);
		System.out.println("@@@@@@@@@");
		objectOutputStream=socketConnection.SocketSend(port, system);
		clientRequestVo.setRequest(request);
		clientRequestVo.setPort(clientInfo[0]);
		clientRequestVo.setSystem(clientInfo[1]);
		clientRequestVo.setNodeName(ClientForm.nodeName);
		clientRequestVo.setTransmissionRate(new Random().nextInt(100));
		objectOutputStream.writeObject(clientRequestVo);
		objectOutputStream.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	
}
public void registration(String request)
{
	try
	{
		objectOutputStream=socketConnection.SocketSend(port, system);
		paymentVO.setRequest(request);
		paymentVO.setPort(clientInfo[0]);
		paymentVO.setSystem(clientInfo[1]);
		//paymentVO.setNodeName(Main.nodeName);
		paymentVO.setTransmissionRate(new Random().nextInt(100));
		objectOutputStream.writeObject(paymentVO);
		objectOutputStream.close();
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
}
